package cn.dujc.superkid.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.List;

import cn.dujc.core.adapter.BaseAdapter;
import cn.dujc.core.adapter.BaseViewHolder;
import cn.dujc.superkid.R;
import cn.dujc.superkid.bean.AnswerListResult;
import cn.dujc.superkid.utils.DateUtil;
import cn.dujc.superkid.utils.ImageLoadHelper;

public class OnlineAnswerAdapter  extends BaseAdapter<AnswerListResult.AnswerEntity> {

    public OnlineAnswerAdapter(@Nullable List<AnswerListResult.AnswerEntity> data) {
        super(data);
        mLayoutResId= R.layout.que_ans_item;
    }

    @Override
    protected void convert(BaseViewHolder helper, AnswerListResult.AnswerEntity item) {

//        private String id;//问题id
//        private String problem_students_id;//提问用户id
//        private String problem_posttime;//提问时间戳
//        private String problem_content;//提问内容
//        private String answer_teacher_id;//回复老师id
//        private String answer_posttime;//回复时间戳
//        private String answer_content;//回复内容
//        private String status;//答疑状态（1-未处理，2-已处理）
//        private String problem_username;//提问者姓名
//        private String problem_avatar;//提问者头像
//        private String answer_teacher_nicename;//回复老师名
//        private String answer_teacher_avatar;//回复老师头像

        long problem_posttime = Long.valueOf(item.getProblem_posttime()).longValue();
        String posttime= DateUtil.formatData("yyyy-MM-dd HH:mm:ss",problem_posttime);
        helper.setText(R.id.que_name,item.getProblem_username());
        helper.setText(R.id.question,item.getProblem_content());
        helper.setText(R.id.que_time,posttime);
        ImageLoadHelper.loadImage((ImageView) helper.getView(R.id.que_icon),item.getProblem_avatar());//暂无头像
        if(item.getStatus().equals("1")){
            helper.setGone(R.id.rl_alreadyprocessed,false);
            helper.setGone(R.id.rl_untreated,true);
        }else {
            long answer_posttime = Long.valueOf(item.getAnswer_posttime()).longValue();
            String posttime2=DateUtil.formatData("yyyy-MM-dd HH:mm:ss",answer_posttime);
            helper.setText(R.id.teacher_time,posttime2);
            ImageLoadHelper.loadImage((ImageView) helper.getView(R.id.teacher_icon),item.getAnswer_teacher_avatar());//暂无头像
            helper.setText(R.id.teacher_name,item.getAnswer_teacher_nicename());
            helper.setText(R.id.teacher_answer,Html.fromHtml(item.getAnswer_content()));
        }
    }
}
